Repository navigation
Add server limits with UTF-16 truncation and bounded IDs - #49
Open
DzmitryHumianiuk wants to merge 2 commits into
Open
DzmitryHumianiuk wants to merge 2 commits into
DzmitryHumianiuk wants to merge 2 commits into
Conversation
Truncate shortens names, descriptions and attributes to the server's limits, counted in UTF-16 code units like the server does and never splitting a character. BoundedID shortens testCaseId/uniqueId to a prefix plus a hash of the whole ID, so long IDs stay unique and stable. The limits are constants taken from the service-api validation rules. Part of #27 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Checked on ReportPortal 6.0.0: a 3000-character key and value are stored as 512/512 (AttributeConverter.MAX_ATTRIBUTE_LENGTH in service-api). The 128 default stays below that, so only the comment and README change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Local ReportPortal 6.0.0 check (same build as demo,
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #27 (slice L2). No dependencies; merges cleanly with L1, L4 and L5.
Pure functions that shorten values to what the server accepts, counted the way the server counts (UTF-16 code units) and never splitting a character. The starting point is
pkg/ginkgo/rpagent/limits.goof PR #15 (at 07ad5c4). Nothing calls them yet: the CLI and the Ginkgo agent adopt them in their own PRs.Changes
pkg/gorp/limits.go(new):MaxLaunchNameLength256,MaxItemNameLength1024,MaxDescriptionLength2048,MaxUniqueIDLength1024,MaxTestCaseIDLength1024,MaxAttributes256,MaxAttributeLength128;Truncate(s, limit): cuts tolimitUTF-16 units and ends with..., like the Java client;BoundedID(id, limit): prefix +~+ 16 hex digits of SHA-256 of the whole ID, so long IDs stay unique and stable;TruncateAttributes(attrs): at most 256 attributes, keys and values of at most 128; returns a new slice.pkg/gorp/limits_test.go(new).Differences from the #15 original:
BoundedIDcounts UTF-16 units. The original compared bytes, so an ID of 400 three-byte characters (400 units, 1200 bytes) was shortened although the server accepts it.Truncatetakes the limit as an argument instead of being bound to item names.utf16.Encodeper character.Limits and their source
service-api
developat 017642e9, paths undersrc/main/java/com/epam/reportportal/base/; migrations at 956ef1ad; client-java 5.4.16-SNAPSHOT at 1d8ecdae.reporting/StartLaunchRQ.java:43(@NotBlankWithSize(max = MAX_NAME_LENGTH)),reporting/ValidationConstraints.java:33reporting/StartTestItemRQ.java:92,reporting/ValidationConstraints.java:29ws/converter/builders/LaunchBuilder.java:43,69-74,TestItemBuilder.java:50,108-113(StringUtils.substring(it.trim(), 0, 2048))uniqueIdreporting/StartTestItemRQ.java:58(@Size(max = MAX_TEST_ITEM_UNIQUE_ID_LENGTH)),ValidationConstraints.java:30testCaseIdws/converter/builders/TestCaseIdEntry.java:33,45-51; columnVARCHAR(1024)in migrations14_test_case_id_size_increase.up.sql:2[hashCode of the rest]reporting/StartRQ.java:53,reporting/FinishExecutionRQ.java:66(@Size(max = MAX_PARAMETERS_LENGTH)),ValidationConstraints.java:36ws/converter/converters/AttributeConverter.java:32-43(MAX_ATTRIBUTE_LENGTH = 512,substring). 128 is the default of the Java client,listeners/ListenerParameters.java:71, and stays below the server cutThe unit is UTF-16: the name validator compares
value.length()(infrastructure/annotations/NotBlankWithSizeValidator.java:58),@Sizeon aStringdoes the same, and the description is cut withsubstring.Points that differ from the plan in #27 and from the Java client:
service/LaunchImpl.java:89,389-399), the server at this commit keeps 2048.MaxDescriptionLengthfollows the server.core/launch/impl/FinishLaunchHandlerImpl.java:110,131-138joins them with a space beforeaddDescriptioncuts.testCaseIdis not rejected and not lost. The server shortens it itself.BoundedIDis still useful there to decide what is stored (the server's hash of the tail is 32-bit), but it isuniqueIdwhere it is needed: a long one fails the request.MAX_ATTRIBUTE_LENGTH = 512exists twice: ininfrastructure/model/ValidationConstraints.java:51(project and filter handlers) and inAttributeConverter.java:32, which reporting uses to cut keys and values. The first version of this description said reporting has no limit; corrected after the live check (see comment).Behaviour change
None. New exported API only.
Verification
On
feat/truncation-limits(36a222d):go build ./... && go vet ./...: okgo test -race ./...: okgo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 run ./...: 0 issuesTests cover: lengths checked against an independent
utf16.Encodecount; a surrogate pair at the cut is not split (emoji, mixed text, limits too small for the mark); BMP characters that are 3 bytes in UTF-8 count as one; invalid UTF-8; the result at every server limit is within the limit and at most one unit short of it;BoundedIDis stable, keeps IDs with a common prefix different, and matches a value computed withshasum -a 256; tiny limits;TruncateAttributeskeeps the input untouched and the order.Investigation log
git fetch origin pull/15/head:pr15-wave,git show 07ad5c4:pkg/ginkgo/rpagent/limits.go; the local branch is deleted again.grep -rn "MAX_\|MIN_" --include=ValidationConstraints.java srcin service-api: two copies of the constants; the reporting DTOs importbase.reporting.ValidationConstraints.grep -n "@Size\|@NotBlank\|MAX_" reporting/{StartRQ,StartLaunchRQ,StartTestItemRQ,AttributeResource,FinishExecutionRQ,ParameterResource}.javagave the annotations in the table.description,codeRef,testCaseIdand parameters carry no size annotation.LaunchBuilder.javaandTestItemBuilder.javashowed the silent cut of descriptions;grep -rn addDescription core/showed that start, finish, stop and rerun all go through the same builders.TestCaseIdEntry.javashowed the server-side cropping oftestCaseId. My first reading (from the column size alone) was that a long ID fails when stored; that was wrong and is corrected.1_initialize_schema.up.sql:386,420(launch.name VARCHAR(256),test_item.name VARCHAR(1024)),4_size_limitations.up.sql:8-9(unique_id VARCHAR(1024),code_ref VARCHAR),14_test_case_id_size_increase.up.sql:2,1_initialize_schema.up.sql:503-504(item_attribute.key/value VARCHAR, no length). PostgreSQL counts characters, Java counts UTF-16 units, so a value within the Java limit always fits the column.92_start_time_idx.up.sql:2creates a btree index onitem_attribute (key, value). A btree entry can't exceed about a third of a page, so very long attributes (kilobytes) may fail to insert. 128 is far below that.Not verified
Nothing here was checked against a live server.Checked later on a local ReportPortal 6.0.0, see the PR comment.commons-modelartifact, which I did not read. The PR Add Ginkgo v2 agent and ginkgo-rp wrapper (pkg/ginkgo) #15 comment reports 1024 for item names and a "silently cut"testCaseIdon a live 5.x, which agrees with the table.🤖 Generated with Claude Code